﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RockScissorPaper
{
    public partial class Form1 : Form
    {
        private int playerWin = 0;
        private int computerWin = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnRock_Click(object sender, EventArgs e)
        {
            
            var fistStr = "石头";
            Play(fistStr);
     
        }
        private void btnScissor_Click(object sender, EventArgs e)
        {
            var fistStr = "剪刀";
            Play(fistStr);
        }

        private void btnPaper_Click(object sender, EventArgs e)
        {
            var fistStr = "布";
            Play(fistStr);
        }
        //游戏调用

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void labComputer_Click(object sender, EventArgs e)
        {

        }

     
        private void Play(string fistStr)
        {
            //玩家出石头
            lblPlayer.Text = fistStr;
            var play = new Player();
            var enumPlayer = play.ShowFirst(fistStr);

            //电脑出拳
            var com = new Computer();
            var enumComputer = com.ShowFist();
            lblComputer.Text = com.Fist.ToString();

            //裁判判定
            var enumResult = Judge.Getresult((int)enumPlayer, (int)enumComputer);
            lblResult.Text = enumResult.ToString();


            if(enumResult==Result.玩家赢)
            {
                playerWin++;
                lblPlayerScore.Text = playerWin.ToString();

            }
            else if(enumResult==Result.电脑赢)
            {
                computerWin++;
                lblComputerScore.Text = computerWin.ToString();
            }
           
        }

    }
}
